#ifndef PLATFORM_H
#define PLATFORM_H
/********************************/
/*函数功能：获取配置信息         */
/*参数1：平台名称                */
/* 返回值1：clientid             */
/* 返回值2：hostname             */
/* 返回值3：username             */
/* 返回值4：topic                */
/* 返回值5：name                 */
/* 返回值6：js                   */
/* 返回值4：password             */
/* 返回值5：keepalive            */
/* 返回值6：port                 */
/********************************/
//结构体
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include "iniparser.h"
#include "dictionary.h"
#include "cJSON.h"
#include "logger.h"

#define INI_PATH  "/home/nbiot/pengjiawei/sms-modem/configure.ini"
#include "sms_modem.h"

typedef struct p_ctx_s {
        char                    platform[32];
        char                    clientid[1024];
        char                    hostname[128];
        char                    username[128];
        char                    topic[128];
        char                    service_id[128];
        char                    id[32];
        char                    password[128];
        char                    clientToken[128];
        char                    type[128];
        char                    get_ip[32];
        char                    logfile[4096];
        char                    recv_message[4096];
        char                    cafile[1024];
        char                    capath[1024];
        char                    certfile[1024];
        char                    keyfile[1024];
        struct mosquitto        *mosq;
        int                     logsize;
        int                     loglevel;
        int                     keepalive;
        int                     port;
        int                     version;



}p_ctx_t;

typedef struct pub_ctx_s{
        char                    pub_topic[128];
        int                     pub_flag;
        int                     connect_flag;
        int                     pub_qos;


}pub_ctx_t;
typedef struct sub_ctx_s{

        char                    sub_topic[128];
        int                     sub_qos;

}sub_ctx_t;
typedef struct log_ctx_s{
        char    logfile[1024];
        int     loglevel;
        int     logsize;
}log_ctx_t;

typedef struct info_ctx_s{
//      char    message[1024];
        char    T_time[128];
        char    name[128];
        float   temperature;
}info_ctx_t;

typedef struct msq_ctx_s{
        p_ctx_t         p_ctx;
        info_ctx_t      info_ctx;
        pub_ctx_t       pub_ctx;
        sub_ctx_t       sub_ctx;
        log_ctx_t       log_ctx;

        //sms_ctx_t             sms;
}msq_ctx_t;


extern int get_config(msq_ctx_t *msq);

int pack_data(msq_ctx_t *msq,char *buf,int size);
//int get_json(msq_ctx_t *msq,char *buf);
//extern  int platform_ctr(char *platform,char *clientid,char *hostname, char *username,char *topic,char *name,char *js,char *password,int keepalive,int port);

#endif
